package com.ytrsoft.im;

import com.ytrsoft.enums.IMType;
import com.ytrsoft.service.UserService;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.stereotype.Component;

@Component
@ServerEndpoint(value = "/chat/video/{from}/{to}")
public class VideoIM extends AbstractIM {

    public VideoIM(UserService userService) {
        super(userService, IMType.VIDEO);
    }

    @Override
    protected void handleMessage(IMPresenter presenter) {
        IMPresenter to = getToPresenter(presenter);
        if (to != null) {
            sendBinary(to, presenter.getStream());
        } else {
            sendError(presenter, "对方不在线");
        }
    }

}
